<table class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="3">页面访问</th>
		</tr> 
	</thead> 
	 <tbody> 
	 	<tr> 
			<td  width="30%">请求路径</td> 
			<td  width="70%" colspan="2">search.htm</td>
		</tr>
		<tr> 
			<td>请求方式</td> 
			<td colspan="2">GET</td>
		</tr>
		<tr> 
			<td>请求参数</td> 
			<td colspan="2"><a style="color: #317ee7" onclick="anchorJump('#anchor_600'); return false;">参数表</a></td> 
		</tr>
		<tr> 
			<td>请求失败返回</td> 
			<td colspan="2">跳转到message模板页显示错误</td> 
		</tr>
		<tr> 
			<td rowspan="7">请求成功返回</td> 
			<td>话题分页</td> 
			<td width="30%" >
				变量：searchResultPage<br>
				类型：<a style="color: #317ee7" onclick="anchorJump('#anchor_10'); return false;">PageView</a>
			</td>
		</tr> 
		<tr>
			<td>搜索关键词</td> 
			<td width="30%" >
				变量：keyword<br>
				类型：String
			</td>
		</tr> 
	</tbody> 
</table>

<table class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="3">页面访问 - AJAX方式</th>
		</tr> 
	</thead> 
	 <tbody> 
	 	<tr> 
			<td  width="30%">请求路径</td> 
			<td  width="70%" colspan="2">search.htm</td>
		</tr>
		<tr> 
			<td>请求方式</td> 
			<td colspan="2">GET</td>
		</tr>
		<tr> 
			<td>自定义请求头</td> 
			<td colspan="2">协议头：X-Requested-With  值：XMLHttpRequest</td>
		</tr>
		<tr> 
			<td>请求参数</td> 
			<td colspan="2"><a style="color: #317ee7" onclick="anchorJump('#anchor_600'); return false;">参数表</a></td> 
		</tr>
		<tr> 
			<td width="30%" rowspan="9">请求返回</td> 
			<td width="30%" rowspan="9">JSON格式值 类型:Map&ltString,Object></td>
			<td width="40%">键参数：success<br>值内容说明：成功返回true 失败返回false<br>值类型：String</td> 
		</tr>
		<tr> 
			<td>键参数：error<br>值内容说明：错误值集合<br>值类型：<a style="color: #317ee7" onclick="anchorJump('#anchor_80'); return false;">Map&ltString,String></a></td> 
		</tr>
		<tr> 
			<td>键参数：searchResultPage<br>值内容说明：话题分页<br>值类型：<a style="color: #317ee7" onclick="anchorJump('#anchor_10'); return false;">PageView</a></td>
		</tr>
	</tbody> 
</table>

<table id="anchor_10" class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="3">分页 PageView</th>
		</tr> 
		<tr> 
			<th width="30%">变量</th> 
			<th width="30%">类型</th>
			<th width="40%">说明</th> 
		</tr> 
	</thead> 
	<tbody> 
		<tr> 
			<td>records</td> 
			<td>List&lt<a style="color: #317ee7" onclick="anchorJump('#anchor_15'); return false;">SearchResult</a>></td>
			<td>数据展示列表</td>
		</tr>
		<tr> 
			<td>pageIndex</td> 
			<td><a style="color: #317ee7" onclick="anchorJump('#anchor_30'); return false;">PageIndex</a></td>
			<td>页码索引</td>
		</tr>
		<tr> 
			<td>totalpage</td> 
			<td>long</td>
			<td>总页数</td>
		</tr>
		<tr> 
			<td>maxresult</td> 
			<td>long</td>
			<td>每页显示记录数</td>
		</tr>
		<tr> 
			<td>currentpage</td> 
			<td>long</td>
			<td>当前页</td>
		</tr>
		<tr> 
			<td>pagecount</td> 
			<td>long</td>
			<td>页码显示总数</td>
		</tr>
		<tr> 
			<td>onUrl</td> 
			<td>String</td>
			<td>上一页URL</td>
		</tr>
		<tr> 
			<td>nextUrl</td> 
			<td>String</td>
			<td>下一页URL</td>
		</tr>
	</tbody> 
</table>
<table id="anchor_30" class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="3">分页索引 PageIndex</th>
		</tr> 
		<tr> 
			<th width="30%">变量</th> 
			<th width="30%">类型</th>
			<th width="40%">说明</th> 
		</tr> 
	</thead> 
	<tbody> 
		<tr> 
			<td>startindex</td> 
			<td>long</td>
			<td>分页开始索引</td>
		</tr>
		<tr> 
			<td>endindex</td> 
			<td>long</td>
			<td>分页结束索引</td>
		</tr>
	</tbody> 
</table>


<table id="anchor_15" class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="5">搜索结果 SearchResult</th>
		</tr> 
		<tr> 
			<th width="30%" colspan="2">变量</th> 
			<th width="30%">类型</th>
			<th width="40%" colspan="2">说明</th> 
		</tr> 
	</thead> 
	<tbody> 
		<tr> 
			<td rowspan="2">indexModule</td> 
			<td><div class="mask"></div></td>
			<td>Integer</td>
			<td colspan="2">索引模块 10:话题 </td>
		</tr>
		<tr> 
			<td>topic</td> 
			<td><a style="color: #317ee7" onclick="anchorJump('#anchor_20'); return false;">Topic</a></td>
			<td colspan="2">话题</td>
		</tr>
		<tr> 
			<td rowspan="2">indexModule</td> 
			<td><div class="mask"></div></td>
			<td>Integer</td>
			<td colspan="2">索引模块 20：问题</td>
		</tr>
		<tr> 
			<td>question</td> 
			<td><a style="color: #317ee7" onclick="anchorJump('#anchor_40'); return false;">Question</a></td>
			<td colspan="2">问题</td>
		</tr>
	</tbody> 
</table>
<table id="anchor_20" class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="4">话题 Topic</th>
		</tr> 
		<tr> 
			<th width="30%">变量</th> 
			<th width="30%">类型</th>
			<th width="40%" colspan="2">说明</th> 
		</tr> 
	</thead> 
	<tbody> 
		<tr> 
			<td>id</td> 
			<td>Long</td>
			<td colspan="2">话题Id</td>
		</tr>
		<tr> 
			<td>title</td> 
			<td>String</td>
			<td colspan="2">标题；本字段高亮字符用&ltB>&lt/B>标签包裹，字段在搜索时已进行安全过滤，可以加上<#noescape></#noescape>标签关闭转义，以输出html标签</td>
		</tr>
		<tr> 
			<td>tagId</td> 
			<td>Long</td>
			<td colspan="2">标签Id</td>
		</tr>
		<tr> 
			<td>tagName</td> 
			<td>String</td>
			<td colspan="2">标签名称</td>
		</tr>
		<tr> 
			<td>content</td> 
			<td>String</td>
			<td colspan="2">话题内容；本字段高亮字符用&ltB>&lt/B>标签包裹，字段在搜索时已进行安全过滤，可以加上<#noescape></#noescape>标签关闭转义，以输出html标签。搜索结果不显示隐藏标签内的内容</td>
		</tr>
		
		<tr> 
			<td>summary</td> 
			<td>String</td>
			<td colspan="2">内容摘要(不含隐藏标签内的内容)</td>
		</tr>
		<tr> 
			<td>postTime</td> 
			<td>Date</td>
			<td colspan="2">发表时间</td>
		</tr>
		<tr> 
			<td>lastReplyTime</td> 
			<td>Date</td>
			<td colspan="2">最后回复时间</td>
		</tr>
		<tr> 
			<td>commentTotal</td> 
			<td>Long</td>
			<td colspan="2">评论总数</td>
		</tr>
		<tr> 
			<td>allow</td> 
			<td>boolean</td>
			<td colspan="2">允许评论</td>
		</tr>
		<tr> 
			<td>viewTotal</td> 
			<td>Long</td>
			<td colspan="2">查看总数</td>
		</tr>
		<tr> 
			<td>userName</td> 
			<td>String</td>
			<td colspan="2">用户名称</td>
		</tr>
		<tr> 
			<td>account</td> 
			<td>String</td>
			<td colspan="2">账号</td>
		</tr>
		<tr> 
			<td>userRoleNameList</td> 
			<td>List&ltString></td>
			<td colspan="2">用户角色名称集合</td>
		</tr>
		<tr> 
			<td>allowRoleViewList</td> 
			<td>List&ltString></td>
			<td colspan="2">话题允许查看的角色名称集合(默认角色除外)</td>
		</tr>
		<tr> 
			<td>nickname</td> 
			<td>String</td>
			<td colspan="2">呢称</td>
		</tr>
		<tr> 
			<td>avatarPath</td> 
			<td>String</td>
			<td>头像路径</td>
			<td width="15%" rowspan="2">页面上显示200*200头像示例${topic.avatarPath}${topic.avatarName}   &nbsp;&nbsp;显示100*100头像示例${topic.avatarPath}100x100/${topic.avatarName}</td> 
		</tr>
		<tr> 
			<td>avatarName</td> 
			<td>String</td>
			<td>头像名称</td>
		</tr>
		<tr> 
			<td>isStaff</td> 
			<td>boolean</td>
			<td colspan="2">是否为员工</td>
		</tr>
	</tbody> 
</table>

<table id="anchor_40" class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="4">问题 Question</th>
		</tr> 
		<tr> 
			<th width="30%">变量</th> 
			<th width="30%">类型</th>
			<th width="40%" colspan="2">说明</th> 
		</tr> 
	</thead> 
	<tbody> 
		<tr> 
			<td>id</td> 
			<td>Long</td>
			<td colspan="2">问题Id</td>
		</tr>
		<tr> 
			<td>title</td> 
			<td>String</td>
			<td colspan="2">标题；本字段高亮字符用&ltB>&lt/B>标签包裹，字段在搜索时已进行安全过滤，可以加上<#noescape></#noescape>标签关闭转义，以输出html标签</td>
		</tr>
		
		<tr> 
			<td>content</td> 
			<td>String</td>
			<td colspan="2">话题内容；本字段高亮字符用&ltB>&lt/B>标签包裹，字段在搜索时已进行安全过滤，可以加上<#noescape></#noescape>标签关闭转义，以输出html标签。搜索结果不显示隐藏标签内的内容</td>
		</tr>
		<tr> 
			<td>summary</td> 
			<td>String</td>
			<td colspan="2">内容摘要</td>
		</tr>
		<tr> 
			<td>postTime</td> 
			<td>Date</td>
			<td colspan="2">发表时间</td>
		</tr>
		<tr> 
			<td>lastAnswerTime</td> 
			<td>Date</td>
			<td colspan="2">最后回答时间</td>
		</tr>
		<tr> 
			<td>answerTotal</td> 
			<td>Long</td>
			<td colspan="2">回答总数</td>
		</tr>
		<tr> 
			<td>allow</td> 
			<td>boolean</td>
			<td colspan="2">允许回答</td>
		</tr>
		<tr> 
			<td>viewTotal</td> 
			<td>Long</td>
			<td colspan="2">查看总数</td>
		</tr>
		<tr> 
			<td>userName</td> 
			<td>String</td>
			<td colspan="2">用户名称</td>
		</tr>
		<tr> 
			<td>account</td> 
			<td>String</td>
			<td colspan="2">账号</td>
		</tr>
		<tr> 
			<td>userRoleNameList</td> 
			<td>List&ltString></td>
			<td colspan="2">用户角色名称集合</td>
		</tr>
		<tr> 
			<td>nickname</td> 
			<td>String</td>
			<td colspan="2">呢称</td>
		</tr>
		<tr> 
			<td>avatarPath</td> 
			<td>String</td>
			<td>头像路径</td>
			<td width="15%" rowspan="2">页面上显示200*200头像示例${question.avatarPath}${question.avatarName}   &nbsp;&nbsp;显示100*100头像示例${question.avatarPath}100x100/${question.avatarName}</td> 
		</tr>
		<tr> 
			<td>avatarName</td> 
			<td>String</td>
			<td>头像名称</td>
		</tr>
		<tr> 
			<td>isStaff</td> 
			<td>boolean</td>
			<td colspan="2">是否为员工</td>
		</tr>
		<tr> 
			<td>essence</td> 
			<td>Boolean</td>
			<td colspan="2">是否为精华</td>
		</tr>
	</tbody> 
</table>


<table id="anchor_80"  class="exampleTable" > 
	<thead> 
		<tr> 
			<th colspan="3">页面访问 搜索 错误值 error</th>
		</tr> 
		<tr> 
			<th width="30%">变量</th> 
			<th width="30%">类型</th>
			<th width="40%">说明</th> 
		</tr> 
	</thead> 
	<tbody> 
	 	<tr> 
			<td>message</td> 
			<td>String</td>
			<td>搜索错误</td>
		</tr>
	</tbody> 
</table>

<table id="anchor_600" class="exampleTable" > 
	<thead>
		<tr> 
			<th colspan="5">请求参数</th>
		</tr>
		<tr> 
			<th width="30%">参数</th> 
			<th width="20%">类型</th> 
			<th width="10%">是否必填</th> 
			<th width="40%" colspan="2">说明</th> 
		</tr> 
	</thead> 
	 <tbody> 
	 	<tr> 
			<td>keyword</td> 
			<td>String</td>
			<td>是</td>
			<td>搜索关键词</td> 
		</tr>	
		<tr> 
			<td>page</td> 
			<td>Integer</td>
			<td>否</td>
			<td>页码</td> 
		</tr>
	</tbody> 
</table>

<h2 style="margin:0;padding:0; margin-top: 10px;">示例</h2>
<textarea name="exampleCode">

<#-- 搜索结果分页 -->
<#if searchResultPage?exists && searchResultPage.records?exists && searchResultPage.records?size gt 0>
	<#list searchResultPage.records as searchResult>
		<#if searchResult.indexModule == 10>
			<#assign topic = searchResult.topic>
			<a href="thread?topicId=${topic.id}" class="title">
				【${topic.tagName}】<span><#noescape>${topic.title}</#noescape></span>
			</a>
			<#-- 话题内容 因为要高亮显示，所以不转义-->
		    <#noescape>${topic.content}</#noescape>
		<#elseif searchResult.indexModule == 20>
			<#assign question = searchResult.question>
			<a href="question?questionId=${question.id}" class="title">
				<span><#noescape>${question.title}</#noescape></span>
			</a>
			<#-- 问题内容 因为要高亮显示，所以不转义-->
		    <#noescape>${question.content}</#noescape>
			
		</#if>
		
	</#list>
</#if>



<#-- 搜索话题和问题 -->
<input type="text" id="keyword" value="${keyword}" onkeydown="javascript:if(event.keyCode==13){ search();}">
<input type="button" value="搜索" class="button" onclick="search();return false">
<script type="text/javascript" language="javascript">
//搜索跳转
function search(){	
	var content =  document.getElementById("keyword").value;
	if(trim(content) == ""){
		return;
	}
	
	//获取系统路径  注意所有网页head标签内都要加入<base href="">标签
	var basePath =  getBasePath();
	//参数
	basePath = basePath+"search?keyword="+encodeURIComponent(content);
	window.location.href = basePath;
	return;
}
</script>
</textarea>
